import { ref, unref } from 'vue';

export const useHandleSelect = emit => {
  const ShTableRef = ref(null);

  /**
   * @description 整合selectChange事件
   * @param {selection} 已选项数据
   * @param {type} select操作
   * @return {Function} onSelectChange
   */
  const onSelectChange = (selection, type) => {
    emit('on-select-change', { selection, type });
  };

  const selectAll = status => {
    unref(ShTableRef).selectAll(status);
  };

  return {
    ShTableRef,
    onSelectChange,
    selectAll,
  };
};
